<?php
namespace Home\Controller;

class indexController extends HomeController
{

    public function index()
    {
        exit('敬请期待');

    }

    public function rd()
    {
        for ($i = 0; $i <= 2000; $i++) {
            $result = $this->random(10);//生成10位字母数字混合字符串
            echo $result . "<br>";
            $data = array(
                'card_sn' => $result,
                'card_type' => 3,
                'coupon_id' => 0,
                'status' => 1,
                'create_time' => NOW_TIME,
                'update_time' => NOW_TIME,
            );
            M('CouponCard')->add($data);
        }


    }

    /**
     * 产生随机字符串
     *
     * @param    int $length 输出长度
     * @param    string $chars 可选的 ，默认为 0123456789
     * @return   string     字符串
     */
    function random($length, $chars = '123456789ABCDEFGHIJKLMNPQRSTUVWXYZ')
    {
        $hash = '';
        $max = strlen($chars) - 1;
        for ($i = 0; $i < $length; $i++) {
            $hash .= $chars[mt_rand(0, $max)];
        }
        return $hash;
    }
}
